#ifndef LINEARPPSPLINES_H
#define LINEARPPSPLINES_H

#include "Spline.h"

class LinearPPSplines:public PPSplines {
    public:
    LinearPPSplines(const std::vector<double>& x_0,const std::vector<double>& f_0):PPSplines(x_0,f_0){
        CalculateCoefficients();
    }
    void CalculateCoefficients() override;
};

void LinearPPSplines::CalculateCoefficients() {
    for(size_t i=0;i<x.size()-1;++i){
        poly[i].coefficients.resize(2);
        poly[i].coefficients[0]=(f[i+1]-f[i])/(x[i+1]-x[i]);//ax+b :a
        poly[i].coefficients[1]=f[i]-poly[i].coefficients[0]*x[i];//ax+b: b
    }
}
#endif
